unit DeconstructUnit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    CheckBox4: TCheckBox;
    CheckBox5: TCheckBox;
    CheckBox6: TCheckBox;
    CheckBox7: TCheckBox;
    CheckBox8: TCheckBox;
    CheckBox9: TCheckBox;
    CheckBox10: TCheckBox;
    CheckBox11: TCheckBox;
    CheckBox12: TCheckBox;
    CheckBox13: TCheckBox;
    CheckBox14: TCheckBox;
    CheckBox15: TCheckBox;
    CheckBox0: TCheckBox;
    Label1: TLabel;
    Button1: TButton;
    Label2: TLabel;
    Label3: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure CheckBox0Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses deconstruction;


procedure Recalc;
var
  x : integer;
begin
  With Form1 do
  begin
    x := 0;
    if checkbox0.checked  then inc(x,$0001);
    if checkbox1.checked  then inc(x,$0002);
    if checkbox2.checked  then inc(x,$0004);
    if checkbox3.checked  then inc(x,$0008);
    if checkbox4.checked  then inc(x,$0010);
    if checkbox5.checked  then inc(x,$0020);
    if checkbox6.checked  then inc(x,$0040);
    if checkbox7.checked  then inc(x,$0080);
    if checkbox8.checked  then inc(x,$0100);
    if checkbox9.checked  then inc(x,$0200);
    if checkbox10.checked then inc(x,$0400);
    if checkbox11.checked then inc(x,$0800);
    if checkbox12.checked then inc(x,$1000);
    if checkbox13.checked then inc(x,$2000);
    if checkbox14.checked then inc(x,$4000);
    if checkbox15.checked then inc(x,$8000);
    Label1.Caption := 'Hex Value: '+HexStr(X);
    Label2.Caption := 'Expression: '+Decompose(X);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  recalc;
end;

procedure TForm1.CheckBox0Click(Sender: TObject);
begin
  Recalc;
end;

end.
